<?php
/**
 * 提现
 */

namespace app\api\controller;

use app\api\model\Withdraw as WithdrawModel;
use app\common\utils\BackNotify;
use think\Request;

class Withdraw extends Common
{

    public  function postAddRecord(Request $request)
    {
        $user_id = $this->checkLoginUser(true);
        
        $amount = $request->post('amount');
        $account= $request->post('account');
        
        if($amount <= 0 || empty($account))
        {
            to_json_encode(400,'参数错误',['status'=>false]);
        }

        $res = WithdrawModel::handleWithDraw($user_id,$amount,$account);
        if(!$res['status'])
        {
            to_json_encode(400,$res['msg'],['status'=>false]);
        }
        BackNotify::addNotifyNum(WithdrawModel::getNotifyParam($res['record_id']));
        to_json_encode(200, 'success', ['status' => true]);

    }
}